import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';

class CarouselViewPage extends StatelessWidget {
  final CarouselController controller = CarouselController(initialItem: 1);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('carousel_view'),
        ),
        body: Container());
    // body: Center(
    // child: ConstrainedBox(
    //     constraints: BoxConstraints(maxHeight: windowHeight * 0.5),
    //     child:
    // CarouselView(
    //   itemExtent: 330,
    //   shrinkExtent: 200,
    //   children: List<Widget>.generate(20, (int index) {
    //     return UncontainedLayoutCard(
    //         index: index, label: 'Item $index');
    //   }),
    // ),
    //   CarouselView.weighted(
    // itemSnapping: true,
    // shrinkExtent: 200,
    // flexWeights: [3, 2, 1],
    // children: List<Widget>.generate(20, (int index) {
    //   return UncontainedLayoutCard(
    //       index: index, label: 'Item $index');
    // }),
    // )
    // ),
    //     ));
  }
}

class UncontainedLayoutCard extends StatelessWidget {
  const UncontainedLayoutCard({
    super.key,
    required this.index,
    required this.label,
  });

  final int index;
  final String label;

  @override
  Widget build(BuildContext context) {
    return ColoredBox(
      color: Colors.primaries[index % Colors.primaries.length].withOpacity(0.5),
      child: Center(
        child: Text(
          label,
          style: const TextStyle(color: Colors.white, fontSize: 20),
          overflow: TextOverflow.clip,
          softWrap: false,
        ),
      ),
    );
  }
}
